package com.myproject.controller;

import com.myproject.vo.Result;
import com.myproject.exception.BusinessException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/test")
public class TestController {

    @GetMapping("/success")
    public Result<String> testSuccess() {
        return Result.success("测试成功");
    }

    @GetMapping("/business-error")
    public Result<String> testBusinessError() {
        throw new BusinessException(1001, "业务异常测试");
    }

    @GetMapping("/system-error")
    public Result<String> testSystemError() {
        // 模拟系统异常
        int result = 1 / 0;
        return Result.success("这行代码不会执行");
    }
}